package drawPropertyCommands;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Stroke;

/**
 * A properties class that contains information to modify the give Graphics2D
 * @author KevinWang
 *
 */
public class GraphicsProperties implements DrawProperties{

    private Stroke stroke;
    private Color color;

    public GraphicsProperties( Stroke stroke, Color color){
        this.stroke = stroke;
        this.color = color;
    }

    public GraphicsProperties(){
        this(new BasicStroke(), Color.black);
    }

    /**
     * This is a command method that will configure the give Graphics2D
     */
    @Override
    public void configure(Graphics2D g) {
        g.setStroke(stroke);
        g.setColor(color);
    }

    /**
     * Setter method for the color of this GraphicsProperties
     * @param color - color to change to
     */
    public void setColor(Color color){
        this.color = color;
    }

    /**
     * Setter method for the stroke of this GraphicsProperties
     * @param stroke - stroke to change to
     */
    public void setStroke(Stroke stroke){
        this.stroke=stroke ;
    }

    /**
     * Getter method for the stroke so that the original properties can be obtained.
     * @return
     */
    public Stroke getStroke(){
        return stroke;
    }
    /**
     * return a clone of the graphicsProperties
     */
    public DrawProperties clone(){
        BasicStroke s = (BasicStroke)stroke;
        return new GraphicsProperties(new BasicStroke(s.getLineWidth(), s.getEndCap(), s.getLineJoin(), s.getMiterLimit(), s.getDashArray(), s.getDashPhase()), new Color(color.getRed(), color.getGreen(), color.getBlue()));
    }

}
